package me.caofeng.dao;

import me.caofeng.pojo.SecurityQuestion;
import me.caofeng.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Copyright © 2017曹峰. All rights reserved.
 *
 * @Prject: mall
 * @Package: me.caofeng.dao
 * @Description:
 * @Author: 曹峰 blog.caofeng.me
 * @Date: 2017-06-15 16:36
 * @Version: V1.0
 */
@Repository
public interface UserMapper {
    int addUser(User user);

    User getUser(@Param("uid") String uid);

    /**
     * @Author:曹峰 blog.caofeng.me
     * @Date: 2017/6/16 9:18
     * @Description: 检测手机号是否已经被注册
    */
    String isExits(@Param("phone") String phone);

    /**
     * @Author:曹峰 blog.caofeng.me
     * @Date: 2017/6/16 19:42
     * @Description:
    */
    User getLoginInfo(@Param("phone") String phone);

    /**
     * 添加安全问题
     * @param questions 安全问题
     * @return 添加的问题数量
     */
    int addSecurityQuestions(@Param("questions") List<SecurityQuestion> questions);

    /**
     * @Author:曹峰 blog.caofeng.me
     * @Date: 2017/6/17 18:18
     * @Description: 获取安全问题数量
    */
    int countSecurityQuestion(@Param("userId") String userId);

    List<SecurityQuestion> getSecurityQuestions(String userId);

    int updateUserInfo(@Param("name") String name,@Param("password") String password,
                       @Param("phone") String phone,@Param("userId") String userId);

    SecurityQuestion getSecurityQuestion(@Param("id") Integer id ,@Param("userId") String userId);

    int updateSecurityQuestion(@Param("id") Integer id , @Param("userId") String userId, @Param("question") SecurityQuestion question);

    int resetPassword(@Param("phone") String phone,
                      @Param("userId") String userId,
                      @Param("password") String password);

}
